package cn.spike.rockcc.fallback;

import cn.spike.rockcc.dto.CourseEsDto;
import cn.spike.rockcc.errorenum.GlobalExceptionCode;
import cn.spike.rockcc.feignclient.SearchFeignClient;
import cn.spike.rockcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author:spike
 * @create:2023-03-16 17:02
 */
@Component
public class SearchFallbackFactory implements FallbackFactory<SearchFeignClient> {
    @Override
    public SearchFeignClient create(Throwable throwable) {
        return new SearchFeignClient() {
            @Override
            public JSONResult save(CourseEsDto courseEsDto) {
                return JSONResult.error(GlobalExceptionCode.SEARCH_EXCEPTION);
            }
        };
    }
}
